import request from '@/utils/request'
export function getSysAppList() {
  return request({ url: `/online/management/admin/sysapp`, method: 'GET'
  })
}
export function getOptionalAppList() {
  return request({ url: `/online/management/admin/sysapp/optional`, method: 'GET'
  })
}
export function getAppInfoPage(params) {
  return request({ url: '/online/management/admin/sysapp/versionlist', params, method: 'GET'
  })
}
export function downloadApp(params) {
  return request({ url: `/online/management/admin/sysapp/${params}/download`, params, method: 'GET'
  })
}
export function deleteApp(appFileId) {
  return request({ url: `/online/management/admin/sysapp/${appFileId}`, method: 'DELETE'
  })
}
export function confirmAppVersion(params) {
  return request({ url: '/online/management/admin/sysapp/confirm-appversion', params, method: 'GET'
  })
}
export function releaseApk(data) {
  return request({ url: '/online/management/admin/sysapp/release-apk', data, method: 'POST'
  })
}
export function grayscalePage(appFileId, params) {
  return request({ url: `/online/management/admin/sysapp/${appFileId}/grayscale/devices`, params, method: 'GET'
  })
}
export function sysProductionRelease(appFileId) {
  return request({ url: `/online/management/admin/sysapp/grayscale/${appFileId}/release`, method: 'POST'
  })
}
export function queryAllSysApp(params) {
  return request({ url: `/online/management/admin/sysapp/all`, params, method: 'GET'
  })
}

export function queryVersionList(params) {
  return request({ url: `/online/management/admin/sysapp/versions/list`, params, method: 'GET'
  })
}

export const uploadApp = (data, config, source) => {
  return request({
    url: '/file-server/file/upload',
    method: 'POST',
    data,
    timeout: 30 * 60 * 1000,
    onUploadProgress: config.onUploadProgress,
    cancelToken: source.token
  })
}
